package cn.ibizlab.odoo.core.odoo_sale.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Isale_payment_acquirer_onboarding_wizard;
import cn.ibizlab.odoo.core.odoo_sale.domain.Sale_payment_acquirer_onboarding_wizard;
import cn.ibizlab.odoo.core.odoo_sale.filter.Sale_payment_acquirer_onboarding_wizardSearchContext;
import cn.ibizlab.odoo.core.odoo_sale.service.ISale_payment_acquirer_onboarding_wizardService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[销售付款获得在线向导] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Sale_payment_acquirer_onboarding_wizardServiceImpl implements ISale_payment_acquirer_onboarding_wizardService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Isale_payment_acquirer_onboarding_wizardClientService sale_payment_acquirer_onboarding_wizardClientService;

    @Override
    public void updateBatch(List<Sale_payment_acquirer_onboarding_wizard> sale_payment_acquirer_onboarding_wizards, int batchSize) {

        //sale_payment_acquirer_onboarding_wizardClientService.updateBatch(sale_payment_acquirer_onboarding_wizards,batchSize) ;

    }

    @Override
    public void createBatch(List<Sale_payment_acquirer_onboarding_wizard> sale_payment_acquirer_onboarding_wizards, int batchSize) {

                        //sale_payment_acquirer_onboarding_wizardClientService.createBatch(sale_payment_acquirer_onboarding_wizards,batchSize) ;

    }

    @Override
    public Sale_payment_acquirer_onboarding_wizard get(Integer id) {
        Isale_payment_acquirer_onboarding_wizard clientModel = sale_payment_acquirer_onboarding_wizardClientService.createModel();
        clientModel.setId(id);
        sale_payment_acquirer_onboarding_wizardClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Sale_payment_acquirer_onboarding_wizard get(Sale_payment_acquirer_onboarding_wizard sale_payment_acquirer_onboarding_wizard) {
        Sale_payment_acquirer_onboarding_wizard retsale_payment_acquirer_onboarding_wizard = this.get(sale_payment_acquirer_onboarding_wizard.getId()) ;
    	BeanCopier copier=BeanCopier.create(retsale_payment_acquirer_onboarding_wizard.getClass(), sale_payment_acquirer_onboarding_wizard.getClass(), false);
        copier.copy(retsale_payment_acquirer_onboarding_wizard, sale_payment_acquirer_onboarding_wizard, null);
        return sale_payment_acquirer_onboarding_wizard ;
    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Isale_payment_acquirer_onboarding_wizard clientModel = sale_payment_acquirer_onboarding_wizardClientService.createModel();
        clientModel.setId(id);
        sale_payment_acquirer_onboarding_wizardClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //sale_payment_acquirer_onboarding_wizardClientService.removeBatch(sale_payment_acquirer_onboarding_wizards) ;

    }

    @Override
    public boolean update(Sale_payment_acquirer_onboarding_wizard sale_payment_acquirer_onboarding_wizard) {
        boolean bOk = false ;
        Isale_payment_acquirer_onboarding_wizard clientModel = this.convert2Model(sale_payment_acquirer_onboarding_wizard,null);
        sale_payment_acquirer_onboarding_wizardClientService.update(clientModel) ;
        this.convert2Domain(clientModel,sale_payment_acquirer_onboarding_wizard) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public boolean create(Sale_payment_acquirer_onboarding_wizard sale_payment_acquirer_onboarding_wizard) {
        boolean bOk = false ;
        Isale_payment_acquirer_onboarding_wizard clientModel = this.convert2Model(sale_payment_acquirer_onboarding_wizard,null);
        sale_payment_acquirer_onboarding_wizardClientService.create(clientModel) ;
        this.convert2Domain(clientModel,sale_payment_acquirer_onboarding_wizard);
        bOk = true ;

        return bOk ;
    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Sale_payment_acquirer_onboarding_wizard> searchDefault(Sale_payment_acquirer_onboarding_wizardSearchContext context) {
        List<Sale_payment_acquirer_onboarding_wizard> list = new ArrayList<Sale_payment_acquirer_onboarding_wizard>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_payment_acquirer_onboarding_wizard> clientModelList = sale_payment_acquirer_onboarding_wizardClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_payment_acquirer_onboarding_wizard clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_payment_acquirer_onboarding_wizard>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据用户查询
     */
    @Override
    public Page<Sale_payment_acquirer_onboarding_wizard> selectByOdoo_create(Integer id){
        Sale_payment_acquirer_onboarding_wizardSearchContext context = new Sale_payment_acquirer_onboarding_wizardSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_payment_acquirer_onboarding_wizard> list = new ArrayList<Sale_payment_acquirer_onboarding_wizard>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_payment_acquirer_onboarding_wizard> clientModelList = sale_payment_acquirer_onboarding_wizardClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_payment_acquirer_onboarding_wizard clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_payment_acquirer_onboarding_wizard>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Sale_payment_acquirer_onboarding_wizard> selectByOdoo_write(Integer id){
        Sale_payment_acquirer_onboarding_wizardSearchContext context = new Sale_payment_acquirer_onboarding_wizardSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_payment_acquirer_onboarding_wizard> list = new ArrayList<Sale_payment_acquirer_onboarding_wizard>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_payment_acquirer_onboarding_wizard> clientModelList = sale_payment_acquirer_onboarding_wizardClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_payment_acquirer_onboarding_wizard clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_payment_acquirer_onboarding_wizard>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Isale_payment_acquirer_onboarding_wizard convert2Model(Sale_payment_acquirer_onboarding_wizard domain , Isale_payment_acquirer_onboarding_wizard model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = sale_payment_acquirer_onboarding_wizardClientService.createModel() ;
        }

         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getManual_nameDirtyFlag())
            model.setManual_name(domain.getManual_name());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getManual_post_msgDirtyFlag())
            model.setManual_post_msg(domain.getManual_post_msg());
         if(domain.getAcc_numberDirtyFlag())
            model.setAcc_number(domain.getAcc_number());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getJournal_nameDirtyFlag())
            model.setJournal_name(domain.getJournal_name());
         if(domain.getPaypal_pdt_tokenDirtyFlag())
            model.setPaypal_pdt_token(domain.getPaypal_pdt_token());
         if(domain.getStripe_secret_keyDirtyFlag())
            model.setStripe_secret_key(domain.getStripe_secret_key());
         if(domain.getStripe_publishable_keyDirtyFlag())
            model.setStripe_publishable_key(domain.getStripe_publishable_key());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getPayment_methodDirtyFlag())
            model.setPayment_method(domain.getPayment_method());
         if(domain.getPaypal_email_accountDirtyFlag())
            model.setPaypal_email_account(domain.getPaypal_email_account());
         if(domain.getPaypal_seller_accountDirtyFlag())
            model.setPaypal_seller_account(domain.getPaypal_seller_account());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
        return model ;
    }

    public Sale_payment_acquirer_onboarding_wizard convert2Domain( Isale_payment_acquirer_onboarding_wizard model ,Sale_payment_acquirer_onboarding_wizard domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Sale_payment_acquirer_onboarding_wizard();
        }

        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getManual_nameDirtyFlag())
            domain.setManual_name(model.getManual_name());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getManual_post_msgDirtyFlag())
            domain.setManual_post_msg(model.getManual_post_msg());
        if(model.getAcc_numberDirtyFlag())
            domain.setAcc_number(model.getAcc_number());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getJournal_nameDirtyFlag())
            domain.setJournal_name(model.getJournal_name());
        if(model.getPaypal_pdt_tokenDirtyFlag())
            domain.setPaypal_pdt_token(model.getPaypal_pdt_token());
        if(model.getStripe_secret_keyDirtyFlag())
            domain.setStripe_secret_key(model.getStripe_secret_key());
        if(model.getStripe_publishable_keyDirtyFlag())
            domain.setStripe_publishable_key(model.getStripe_publishable_key());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getPayment_methodDirtyFlag())
            domain.setPayment_method(model.getPayment_method());
        if(model.getPaypal_email_accountDirtyFlag())
            domain.setPaypal_email_account(model.getPaypal_email_account());
        if(model.getPaypal_seller_accountDirtyFlag())
            domain.setPaypal_seller_account(model.getPaypal_seller_account());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        return domain ;
    }


}
